package com.k1998.mybatis.controller;

import com.k1998.mybatis.bean.JxIndex;
import com.k1998.mybatis.dao.IJxIndexDao;
import com.k1998.mybatis.service.JxIndexService;
import com.k1998.mybatis.utils.BatchInfo;
import com.k1998.mybatis.utils.JxUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: ChenYuxiang
 * @Description: //计协查找索引
 * @Param:
 * @return:
 * @Date: 17:32 2021/2/20
 **/
@RestController
@Api(value = "计协查找索引Api文档" , tags = {"计协查找索引Api文档"})
public class JxIndexController {

    @Autowired
    private IJxIndexDao iJxIndexDao;
    @Autowired
    private JxIndexService jxIndexService;

    @PostMapping("/allJxIndex")
    @ApiOperation(value = "查找所有索引", notes = "查找所有索引")
    public String getAll(){return jxIndexService.getAllJxindexs();}

    @PostMapping("/insertJxIndex")
    @ApiOperation(value = "增加索引", notes = "增加索引")
    public String insertJxIndex(@RequestBody JxIndex jxIndex){
        return iJxIndexDao.insertJxIndex(jxIndex)>0? "success" : "error";
    }

    @PostMapping("/updateJxindex")
    @ApiOperation(value = "更新索引",notes = "更新索引")
    public String updateJxIndex(@RequestBody JxIndex jxIndex){
        return iJxIndexDao.updateJxIndex(jxIndex)>0? "success" : "error";
    }

    @PostMapping("/batchDeleteJxIndex")
    @ApiOperation(value = "批量删除索引",notes ="批量删除索引")
    public String batchDeleteJxIndex(@RequestBody BatchInfo batchInfo){
        return jxIndexService.batchJudge(batchInfo.getIds())==1? "success" : "error";
    }

}
